In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
Professor Byteasar prepares a report for Interbyteotian Commission for Climate Change. This report should demonstrate clearly, unambiguously and without any doubt, the impact of Byteotian population on climate changes in the region. Although the Professor has a lot of empirical data, but to pervade the mainstream media, it not enough to present substantive arguments. Equally important is to present data clearly and correctly targeted. To this end, he wants to select the data, to be presented on the main chart in the report, thoughtfully and in a deliberate way.
The key graph will contain information about the average air temperature throughout the years. The Professor has data available concerning the mean annual temperatures for the last years. He wants to describe this graph using the following comment: "in the year the temperature was the lowest, and in the year it was the highest, therefore, it is clear that ...". Unfortunately, he fears that the same minimum or maximum temperature can occur several times throughout this period, and therefore such information could undermine the clearness of his statement.
Professor has therefore decided to present only part of the data on his chart. His idea is to select the year range in such a way that this interval will include exactly one year with a minimum temperature within that range and exactly one year with a maximum temperature also within that range. The selected range may not include the year with the globally maximum or minimum average temperature in the last years (or none of them). Of course, the Professor would like to put as much data as possible on this chart, so he is interested in the longest year span.
The first line of input contains one integer (), denoting the number of years for which the Professor knows the average temperatures. The second line contains a sequence of integers (). The number denotes the average temperature in the -th year.
The output should contain two integers and . They indicate that the longest interval satisfying the Professor's conditions is of length of years, and the earliest year in which such an interval may begin is .
For the input data:
10 8 3 2 5 2 3 4 6 3 6
the correct result is:
6 4
Explanation of the example: The chart will present temperatures 5, 2, 3, 4, 6, 3. This interval contains exactly one year with a minimum temperature of 2 and one year with a maximum temperature of 6.
Task authors: Jacek Tomasiewicz i Tomasz Idziaszek.
<Submit a solution> [0/1]